<template>
	<view>
		<navbar></navbar>
		<view class="container">
			<!-- <view class="Top_tilte">
				账户管理
			</view> -->
			<view class="List_entrance">
				<view class="List_item2 lianlian" @tap.stop.prevent="NavRouter(3)" >
					<!-- <view class="pay_name">
						连连钱包
					</view> -->
					<view class="is_ll_withhold" v-if="!is_ll_withhold">
						暂未开通连连钱包
					</view>
					<view class="openAccount" v-if="!isOpenStatus.is_open_lianlian">
						<text style="color: #fff;">
							去开户
						</text>
					</view>
					<view class="openAccount" v-else>
						<text style="color: #fff;">
							已开户
						</text>
					</view>
					<!-- <view class="icon">
						<image src="@/static/images/user/icon_right.png" mode=""></image>
					</view> -->
				</view>

			</view>
			<!-- 验证码弹窗 -->
			<input-alert ref="qrcode" :show="inputAlert.show" title="请输入验证码" placeholder="验证码" :params="inputAlert.params"
				@cancel="onInputAlertCancel" @confirm="onInputAlertConfirm"></input-alert>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				inputAlert: {
					show: false,
					params: null,
				},
				recharge: {},
				linked_acctno: '',
				is_ll_withhold: uni.getStorageSync('is_ll_withhold'),
				isOpenStatus: uni.getStorageSync("isOpenStatus"),
				// #ifdef APP-PLUS
				ClickList: ['安全密码管理','连连支付密码管理', '连连银行卡管理', '连连钱包管理','杉德钱包管理','地址管理']
				// #endif
				// #ifndef APP-PLUS
				ClickList: ['安全密码管理','连连支付密码管理', '连连银行卡管理', '连连钱包管理','杉德钱包管理','地址管理']
				// #endif
				
			};
		},
		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			console.log(this.isOpenStatus)
		},
		onPullDownRefresh() {
			uni.stopPullDownRefresh();
		},
		methods:{
			onToggleInputAlert: function() {
				this.inputAlert.show = !this.inputAlert.show;
			},
			onInputAlertCancel: function() {
				this.onToggleInputAlert();
					// 跳转到订单
			},
			onInputAlertConfirm: function(value, target, params) {
				this.requestValidationSms(value, params);
			},
			// 校验验证码
			requestValidationSms: function(verify_code, params) {
					  let _this = this
					  let data = {
						sale_id: '',
					  	oid_partner: _this.recharge.oid_partner,
					  	txn_seqno: _this.recharge.order_no,
					  	total_amount: _this.recharge.money,
					  	token: _this.recharge.lianliantoken,
					  	verify_code: verify_code
					  }
					  // 校验验证码
					  app._post_form('user.dealer.recharge/sms', {
					  	data: JSON.stringify(data)
					  }, function(result) {
					  	if (1 == result.code) {
					  		// 隐藏验证码输入框
					  		_this.onInputAlertCancel();
					  		app.showToast('交易成功');
							// 跳转签约
							app._post_form('user/getLianLianWithhold', {}, function(result) {
								console.log(result)
								if (1 == result.code) {
									app.navigationTo(result.data.gateway_url)
								}else{
									app.showError(result.data.msg);
								}
							}, null, function() {
								// 解除按钮禁用
								app.showError(result.msg);
							});
					  	}
					  }, null, function() {
					  	_this.$refs.qrcode.over()
					  });
				// paymentUtils.requestLLBalancePay(verify_code, params, (res)=> {
				// 	// 支付成功
				// 	this.onToggleInputAlert();
				// 	app.showSuccessWithDuration(500, res.msg, () => {
				// 		this.redirectToOrderIndex();
				// 	});
				// });
			},
			/**
			 * 点击列表跳转
			 * index：对应索引
			 */
			huifupay(){
				uni.showToast({
					title: '敬请期待',
					icon: 'none'
				})
			},
			NavRouter(index){
				let _this = this
				// #ifdef APP-PLUS
				console.log(index)
				if(index == 0){
				 	uni.navigateTo({
				 		url: `../setting/security`
				 	});
				 }else if(index == 1){
					plus.runtime.openURL(`https://www.btcys.com/pages/user/modify/index?token=${123}`)
				 }else if(index == 2){
					plus.runtime.openURL(`https://www.btcys.com/pages/user/bank/bank?token=${123}`)
				 }else if(index == 3){
					if(this.isOpenStatus.is_open_lianlian){
						uni.navigateTo({
							url: `../wallet/index`
						});
					}else{
						uni.showModal({
							title: '请前往H5页面开户'
						})
						plus.runtime.openURL(`https://api.btcys.com/#/pages/user/realName/index?token=${123}`)
					}
				}else if(index == 4){
					// 杉德钱包
					app._post_form('user/getSanDeWallet', {}, function(result) {
						console.log(result)
						if (1 == result.code) {
							app.navigationTo(result.data.pay_url)
						}else{
							app.showError(result.msg);
						}
					}, null, function() {
						// 解除按钮禁用
						app.showError(result.msg);
					});
				}else if(index == 5){
					uni.navigateTo({
						url: `../addressManagement/index`
					});
				}
				// #endif
				// #ifndef APP-PLUS
				console.log(index)
				if(index == 0){
					uni.navigateTo({
						url: `../setting/security`
					});
				}else if(index == 1){
				 	uni.redirectTo({
				 		url: `../modify/index`
				 	});
				 }
				 else if(index == 2){
					uni.redirectTo({
						url: `../bank/bank`
					});
				}
				else if(index == 3){
					if(this.isOpenStatus.is_open_lianlian){
						console.log(this.is_ll_withhold)
						if(this.is_ll_withhold == 1){
							uni.navigateTo({
								url: `../wallet/index`
							});
						}else{
							uni.showModal({
								content: '您还未开通钱包，须支付10元管理费开通钱包，是否开通?',
								showCancel: true,
								cancelText: '我再想想',
								confirmText: '去开通',
								success: function (res) {
									if (res.confirm) {
										// 判断用户是否付过签约费用
										app._post_form('user/lianLianWithholdAcc', {}, function(result) {
											console.log(result)
											if (1 == result.code) {
												if (8888 == result.data.ret_code) {
													// 显示验证码弹窗
													_this.inputAlert.show = true;
													_this.recharge = result.data
												} else {
													if(result.data.ret_code == '0000'){
														app._post_form('user/getLianLianWithhold', {}, function(result) {
															console.log(result)
															if (1 == result.code) {
																app.navigationTo(result.data.gateway_url)
															}else{
																app.showError(result.data.msg);
															}
														}, null, function() {
															// 解除按钮禁用
															app.showError(result.msg);
														});
													}else{
														app.showToast(result.data.msg)
													}
												}
											}else{
												// app.showError(result.data.msg);
											}
										}, null, function() {
											// 解除按钮禁用
											app.showError(result.msg);
										});
									} 
									
								}
							})
							
							// this.getBankList()
							// 签约前先扣10元
							// let linked_acctno = uni.getStorageSync('linked_acctno')
							
							
						}
						
					}else{
						uni.navigateTo({
							url: `../realName/index`
						});
						// app._post_form('user/openacct', {}, function(result) {
						// 	console.log(result)
						// 	if (1 == result.code) {
						// 		app.navigationTo(result.data.gateway_url)
						// 	}else{
						// 		app.showError(result.msg);
						// 	}
						// }, null, function() {
						// 	// 解除按钮禁用
						// 	app.showError(result.msg);
						// });
					}
					
				}else if(index == 4){
					app._post_form('user/getSanDeWallet', {}, function(result) {
						console.log(result)
						if (1 == result.code) {
							app.navigationTo(result.data.pay_url)
						}else{
							app.showError(result.msg);
						}
					}, null, function() {
						// 解除按钮禁用
						app.showError(result.msg);
					});
				}else if(index == 5){
					uni.navigateTo({
						url: `../addressManagement/index`
					});
				}
				// #endif
				
			}
		}
	}
</script>

<style lang="scss">
	.container {
		height: 100vh;
		background-color: #FFF;
		// padding: 50rpx;
	}
	.Bottom_boder{
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
	}

	.Top_tilte {
		margin-top: 40rpx;
		width: 100%;
		height: 80rpx;
		background-color: #FFFFFF;
		text-align: center;
		color: rgba(0, 0, 0, 0.9);
		font-size: 30rpx;
		font-family: 'dy-iconfont';
		font-weight: bold;
		line-height: 80rpx;
	}

	.List_entrance {
		// margin: 0 auto;
		display: flex;
		justify-content: center;
		padding-top: 60rpx;
		border-radius: 20rpx;
		background-color: #FFFFFF;
		box-shadow: 0rpx 4rpx 6rpx 1rpx rgba(0, 0, 0, 0.02);
		// padding: 0 30rpx;

		.List_item {
			height: 100rpx;
			background-color: #FFF;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 28rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.9);
			.icon{
				width: 32rpx;
				height: 32rpx;
				image{
					width: 100%;
					height: 100%;
				}
			}
		}
		.lianlian{
			background: url('../../../static/images/lianlianpay.png') no-repeat;
			background-size: 100%;
		}
		.shande{
			background: url('../../../static/images/shandepay.png') no-repeat;
			background-size: 100%;
		}
			
		.List_item2 {
			position: relative;
			margin-bottom: 20rpx;
			height: 280rpx;
			width: 660rpx;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 28rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.9);
			.pay_name{
				font-size: 40rpx;
				color: #FFF;
				font-weight: 600;
				margin-left: 20rpx;
			}
			.icon{
				width: 32rpx;
				height: 32rpx;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.openAccount{

				// background-color: #ffaa00;
				// border-radius: 50rpx 0 50rpx 0;
				padding: 15rpx;
				font-size: 26rpx;
				font-weight: 600;
				position: absolute;
				// left: 625rpx;
				right: 0rpx;
				bottom: 0rpx;
				// top: 50rpx;
			}
		}
		.is_ll_withhold{
			font-size: 30rpx;
			font-weight: 600;
			position: absolute;
			bottom: 30rpx;
			left: 50rpx;
			color: #ffffff;
			background-color: #ffbb0e;
			padding: 5rpx 10rpx;
			border-radius: 50rpx;
		}
	}
</style>
